import {
  exportUrl,
  getLineCodeList,
  getProductProcessCodeList,
  getWorkCellCodeList,
  getWorkTeamCodeList,
  getUserCodeList,
  getSimulatedTypeList,
  getProdOrderTypeList,
  getBomVersionNumberList
} from "@/api/report/mesScanRecord"
// 列表头按钮配置
export const operateList = [
  {
    name: $i18n.t("common.export"),
    type: "primary",
    icon: "el-icon-download",
    handleName: "export", //点击时返回的标识
    url: exportUrl
    //auth: "auth:operlog:export", //权限字段
  }
  // {
  //   name: "新增",
  //   type: "primary",
  //   icon: "el-icon-circle-plus-outline",
  //   handleName: "add", //点击时返回的标识
  // },
  // {
  //   name: $i18n.t("common.delete"),
  //   type: "danger",
  //   icon: "el-icon-delete",
  //   handleName: "deleteBatch", //点击时返回的标识
  // },
]
// 行末按钮配置
export const rowConfig = [
  {
    name: $i18n.t("common.edit"),
    type: "primary",
    class: "row-btn-primary",
    handleName: "edit" //点击时返回的标识
  },
  {
    name: $i18n.t("common.details"),
    type: "info",
    class: "row-btn-info",
    handleName: "detail" //点击时返回的标识
  },
  {
    name: $i18n.t("common.delete"),
    type: "danger",
    class: "row-btn-danger",
    handleName: "delete" //点击时返回的标识
  }
]
// 搜索条件配置
export const searchConfig = {
  data() {
    const _this = this
    return {
      searchDialog: {
        inline: true,
        formDesc: {
          barcode: {
            type: "input",
            label: $i18n.t("mesScanRecord.barcode")
          },
          lineCode: {
            type: "select",
            label: $i18n.t("mesScanRecord.productLine"),
            prop: {
              value: "modelingCode",
              text: "modelingName"
            },
            options: async (data) => {
              const params = {
                modelingCode: _this.$store.getters.factoryCode,
                level: 5
              }
              const list = await getLineCodeList(params)
              return list.data.result
            }
          },
          // lineName: {
          //   type: "input",
          //   label: "生产线体名称",
          // },
          productProcessCode: {
            type: "select",
            label: $i18n.t("mesScanRecord.productProcess"),
            prop: {
              value: "processCode",
              text: "processName"
            },
            options: async (data) => {
              const list = await getProductProcessCodeList()
              return list.data.result
            }
            // on: {
            //   change: (val) => {
            //     that.handleSelectLine(val)
            //   }
            // }
          },
          // productProcessName: {
          //   type: "input",
          //   label: "生产工序名称",
          // },
          workCellCode: {
            type: "select",
            label: $i18n.t("mesScanRecord.collectedWorkCell"),
            prop: {
              value: "modelingCode",
              text: "modelingName"
            },
            options: async (data) => {
              const params = {
                modelingCode: _this.$store.getters.factoryCode,
                level: 6
              }
              const list = await getLineCodeList(params)
              return list.data.result
            }
          },
          // workCellName: {
          //   type: "input",
          //   label: "采集工位名称",
          // },
          // workTeamCode: {
          //   type: "select",
          //   label: "采集班组编码",
          //   type: 'select',
          //   prop: {
          //     value: "value",
          //     text: "description",
          //   },
          //   options: async (data) => {
          //     const list = await getWorkTeamCodeList()
          //     return list.data.result
          //   },
          // },
          // workTeamName: {
          //   type: "input",
          //   label: "采集班组名称",
          // },
          // userCode: {
          //   type: "input",
          //   label: "扫描人员工号",
          // type: 'select',
          // prop: {
          //   value: "value",
          //   text: "description",
          // },
          // options: async (data) => {
          //   const list = await getUserCodeList()
          //   return list.data.result
          // },
          // },
          // userName: {
          //   type: "input",
          //   label: "扫描人员",
          // },
          // scanTime: {
          //   type: "datetimerange",
          //   label: $i18n.t("mesScanRecord.scanTime"),
          //   attrs: {
          //     valueFormat: "yyyy-MM-dd HH:mm:ss",
          //     searchArrKey: ["scanTimeMin", "scanTimeMax"]
          //   }
          // },
          orderCode: {
            type: "input",
            label: $i18n.t("mesScanRecord.productWorkOrder")
          },
          // prodCode: {
          //   type: "input",
          //   label: "产品编码",
          // },
          prodName: {
            type: "input",
            label: $i18n.t("mesScanRecord.prodName")
          }
          // seriesCode: {
          //   type: "input",
          //   label: "系列编码",
          // },
          // seriesName: {
          //   type: "input",
          //   label: "系列名称",
          // },
          // simulatedType: {
          //   type: "select",
          //   label: "虚实订单类型",
          //   type: 'select',
          //   prop: {
          //     value: "value",
          //     text: "description",
          //   },
          //   options: async (data) => {
          //     const list = await getSimulatedTypeList()
          //     return list.data.result
          //   },
          // },
          // prodOrderType: {
          //   type: "select",
          //   label: "生产订单类型",
          //   type: 'select',
          //   prop: {
          //     value: "value",
          //     text: "description",
          //   },
          //   options: async (data) => {
          //     const list = await getProdOrderTypeList()
          //     return list.data.result
          //   },
          // },
        }
      }
    }
  }
}
// 新增/删除表单配置
export const formDescDialog = {
  data() {
    const _this = this
    return {
      span: 24,
      disabled: false,
      isShowSubmitBtn: true,
      formDesc: {
        barcode: {
          type: "input",
          label: $i18n.t("mesScanRecord.barcode2"),
          layout: 12,
          required: false
        },
        lineCode: {
          type: "select",
          label: $i18n.t("mesScanRecord.lineCode"),
          layout: 12,
          required: false,
          prop: {
            value: "value",
            text: "description"
          },
          options: async (data) => {
            const params = {
              modelingCode: _this.$store.getters.factoryCode,
              level: 5
            }
            const list = await getLineCodeList(params)
            return list.data.result
          }
        },
        lineName: {
          type: "input",
          label: $i18n.t("mesScanRecord.lineName"),
          layout: 12,
          required: false
        },
        productProcessCode: {
          type: "select",
          label: $i18n.t("mesScanRecord.productProcessCode"),
          layout: 12,
          required: false,
          prop: {
            value: "value",
            text: "description"
          },
          options: async (data) => {
            const list = await getProductProcessCodeList()
            return list.data.result
          }
        },
        productProcessName: {
          type: "input",
          label: $i18n.t("mesScanRecord.productProcessName"),
          layout: 12,
          required: false
        },
        workCellCode: {
          type: "select",
          label: $i18n.t("mesScanRecord.workCellCode"),
          layout: 12,
          required: false,
          prop: {
            value: "value",
            text: "description"
          },
          options: async (data) => {
            const list = await getWorkCellCodeList()
            return list.data.result
          }
        },
        workCellName: {
          type: "input",
          label: $i18n.t("mesScanRecord.workCellName"),
          layout: 12,
          required: false
        },
        workTeamCode: {
          type: "select",
          label: $i18n.t("mesScanRecord.workTeamCode"),
          layout: 12,
          required: false,
          prop: {
            value: "value",
            text: "description"
          },
          options: async (data) => {
            const list = await getWorkTeamCodeList()
            return list.data.result
          }
        },
        workTeamName: {
          type: "input",
          label: $i18n.t("mesScanRecord.workTeamName"),
          layout: 12,
          required: false
        },
        workShiftCode: {
          type: "input",
          label: $i18n.t("mesScanRecord.workShiftCode"),
          layout: 12,
          required: false
        },
        workShiftName: {
          type: "input",
          label: $i18n.t("mesScanRecord.workShiftName"),
          layout: 12,
          required: false
        },
        userCode: {
          type: "select",
          label: $i18n.t("mesScanRecord.userCode"),
          layout: 12,
          required: false,
          prop: {
            value: "value",
            text: "description"
          },
          options: async (data) => {
            const list = await getUserCodeList()
            return list.data.result
          }
        },
        userName: {
          type: "input",
          label: $i18n.t("mesScanRecord.userName"),
          layout: 12,
          required: false
        },
        scanTime: {
          type: "datetime",
          label: $i18n.t("mesScanRecord.scanTime"),
          layout: 12,
          required: false,
          attrs: {
            valueFormat: "yyyy-MM-dd HH:mm:ss"
          }
        },
        orderCode: {
          type: "input",
          label: $i18n.t("mesScanRecord.orderCode2"),
          layout: 12,
          required: false
        },
        // workOrderCode: {
        //   type: "input",
        //   label: "工单编码(预留)",
        //   layout: 12,
        //   required: false,
        // },
        // workOrderNode: {
        //   type: "input",
        //   label: "工单名称(预留)",
        //   layout: 12,
        //   required: false,
        // },
        prodCode: {
          type: "input",
          label: $i18n.t("mesScanRecord.prodCode"),
          layout: 12,
          required: false
        },
        prodName: {
          type: "input",
          label: $i18n.t("mesScanRecord.prodName"),
          layout: 12,
          required: false
        },
        seriesCode: {
          type: "input",
          label: $i18n.t("mesScanRecord.seriesCode"),
          layout: 12,
          required: false
        },
        seriesName: {
          type: "input",
          label: $i18n.t("mesScanRecord.seriesName"),
          layout: 12,
          required: false
        },
        simulatedType: {
          type: "select",
          label: $i18n.t("mesScanRecord.simulatedType"),
          layout: 12,
          required: false,
          prop: {
            value: "value",
            text: "description"
          },
          options: async (data) => {
            const list = await getSimulatedTypeList()
            return list.data.result
          }
        },
        prodOrderType: {
          type: "select",
          label: $i18n.t("mesScanRecord.prodOrderType"),
          layout: 12,
          required: false,
          prop: {
            value: "value",
            text: "description"
          },
          options: async (data) => {
            const list = await getProdOrderTypeList()
            return list.data.result
          }
        },
        // bomVersionNumber: {
        //   type: "select",
        //   label: "BOM配方版本号",
        //   layout: 12,
        //   required: false,
        //   prop: {
        //     value: "value",
        //     text: "description",
        //   },
        //   options: async (data) => {
        //     const list = await getBomVersionNumberList();
        //     return list.data.result;
        //   },
        // },
        // recordType: {
        //   type: "number",
        //   label: "类型",
        //   layout: 12,
        //   required: false,
        // },
        checkResult: {
          type: "number",
          label: $i18n.t("mesScanRecord.checkResult"),
          layout: 12,
          required: false
        },
        overStationNum: {
          type: "number",
          label: $i18n.t("mesScanRecord.overStationNum"),
          layout: 12,
          required: false
        },
        factoryCode: {
          type: "input",
          label: $i18n.t("mesScanRecord.factoryCode"),
          layout: 12,
          required: false
        },
        Remark: {
          type: "textarea",
          label: $i18n.t("mesScanRecord.Remark"),
          layout: 12,
          required: false
        },
        workDate: {
          type: "date",
          label: $i18n.t("mesScanRecord.workDate"),
          layout: 12,
          required: false,
          attrs: {
            valueFormat: "yyyy-MM-dd"
          }
        }
      }
    }
  }
}
